package ServerTester;

import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.CORBA.*;

import Bibl.*;

public class Klient
    {

    /**
     * @param args
     */
    public static void main( String[] args )
        {
        try
            {
            ORB orb = ORB.init( args, null );

            // get the root naming context
            org.omg.CORBA.Object objRef = orb
                    .resolve_initial_references( "NameService" );
            // Use NamingContextExt instead of NamingContext. This is
            // part of the Interoperable naming Service.
            NamingContextExt ncRef = NamingContextExtHelper.narrow( objRef );

            // resolve the Object Reference in Naming

            Biblioteka ibibl = Bibl.BibliotekaHelper.narrow( ncRef
                    .resolve_str( "BibliotekaObject" ) );
            System.out.println( "Obtained a handle on server object: " + ibibl );
            
            Osoba o = new Osoba( "Zofia", "Fatalska", "Obozowa 10", "", "haslo" );
            ibibl.dodajCzytelnika( o );
            } 
        catch( Exception e )
            {
            System.out.println( "ERROR : " + e );
            e.printStackTrace( System.out );
            }

        }

    }
